// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using System;
using System.Linq;
using Elastic.Clients.Elasticsearch.Serialization;

namespace Elastic.Clients.Elasticsearch.Json;

public sealed partial class CommonStatsFlagConverter : System.Text.Json.Serialization.JsonConverter<Elastic.Clients.Elasticsearch.CommonStatsFlag>
{
	private static readonly System.Text.Json.JsonEncodedText MemberAll = System.Text.Json.JsonEncodedText.Encode("_all");
	private static readonly System.Text.Json.JsonEncodedText MemberBulk = System.Text.Json.JsonEncodedText.Encode("bulk");
	private static readonly System.Text.Json.JsonEncodedText MemberCompletion = System.Text.Json.JsonEncodedText.Encode("completion");
	private static readonly System.Text.Json.JsonEncodedText MemberDenseVector = System.Text.Json.JsonEncodedText.Encode("dense_vector");
	private static readonly System.Text.Json.JsonEncodedText MemberDocs = System.Text.Json.JsonEncodedText.Encode("docs");
	private static readonly System.Text.Json.JsonEncodedText MemberFielddata = System.Text.Json.JsonEncodedText.Encode("fielddata");
	private static readonly System.Text.Json.JsonEncodedText MemberFlush = System.Text.Json.JsonEncodedText.Encode("flush");
	private static readonly System.Text.Json.JsonEncodedText MemberGet = System.Text.Json.JsonEncodedText.Encode("get");
	private static readonly System.Text.Json.JsonEncodedText MemberIndexing = System.Text.Json.JsonEncodedText.Encode("indexing");
	private static readonly System.Text.Json.JsonEncodedText MemberMappings = System.Text.Json.JsonEncodedText.Encode("mappings");
	private static readonly System.Text.Json.JsonEncodedText MemberMerge = System.Text.Json.JsonEncodedText.Encode("merge");
	private static readonly System.Text.Json.JsonEncodedText MemberQueryCache = System.Text.Json.JsonEncodedText.Encode("query_cache");
	private static readonly System.Text.Json.JsonEncodedText MemberRecovery = System.Text.Json.JsonEncodedText.Encode("recovery");
	private static readonly System.Text.Json.JsonEncodedText MemberRefresh = System.Text.Json.JsonEncodedText.Encode("refresh");
	private static readonly System.Text.Json.JsonEncodedText MemberRequestCache = System.Text.Json.JsonEncodedText.Encode("request_cache");
	private static readonly System.Text.Json.JsonEncodedText MemberSearch = System.Text.Json.JsonEncodedText.Encode("search");
	private static readonly System.Text.Json.JsonEncodedText MemberSegments = System.Text.Json.JsonEncodedText.Encode("segments");
	private static readonly System.Text.Json.JsonEncodedText MemberShardStats = System.Text.Json.JsonEncodedText.Encode("shard_stats");
	private static readonly System.Text.Json.JsonEncodedText MemberSparseVector = System.Text.Json.JsonEncodedText.Encode("sparse_vector");
	private static readonly System.Text.Json.JsonEncodedText MemberStore = System.Text.Json.JsonEncodedText.Encode("store");
	private static readonly System.Text.Json.JsonEncodedText MemberTranslog = System.Text.Json.JsonEncodedText.Encode("translog");
	private static readonly System.Text.Json.JsonEncodedText MemberWarmer = System.Text.Json.JsonEncodedText.Encode("warmer");

	public override Elastic.Clients.Elasticsearch.CommonStatsFlag Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options)
	{
		if (reader.ValueTextEquals(MemberAll))
		{
			return Elastic.Clients.Elasticsearch.CommonStatsFlag.All;
		}

		if (reader.ValueTextEquals(MemberBulk))
		{
			return Elastic.Clients.Elasticsearch.CommonStatsFlag.Bulk;
		}

		if (reader.ValueTextEquals(MemberCompletion))
		{
			return Elastic.Clients.Elasticsearch.CommonStatsFlag.Completion;
		}

		if (reader.ValueTextEquals(MemberDenseVector))
		{
			return Elastic.Clients.Elasticsearch.CommonStatsFlag.DenseVector;
		}

		if (reader.ValueTextEquals(MemberDocs))
		{
			return Elastic.Clients.Elasticsearch.CommonStatsFlag.Docs;
		}

		if (reader.ValueTextEquals(MemberFielddata))
		{
			return Elastic.Clients.Elasticsearch.CommonStatsFlag.Fielddata;
		}

		if (reader.ValueTextEquals(MemberFlush))
		{
			return Elastic.Clients.Elasticsearch.CommonStatsFlag.Flush;
		}

		if (reader.ValueTextEquals(MemberGet))
		{
			return Elastic.Clients.Elasticsearch.CommonStatsFlag.Get;
		}

		if (reader.ValueTextEquals(MemberIndexing))
		{
			return Elastic.Clients.Elasticsearch.CommonStatsFlag.Indexing;
		}

		if (reader.ValueTextEquals(MemberMappings))
		{
			return Elastic.Clients.Elasticsearch.CommonStatsFlag.Mappings;
		}

		if (reader.ValueTextEquals(MemberMerge))
		{
			return Elastic.Clients.Elasticsearch.CommonStatsFlag.Merge;
		}

		if (reader.ValueTextEquals(MemberQueryCache))
		{
			return Elastic.Clients.Elasticsearch.CommonStatsFlag.QueryCache;
		}

		if (reader.ValueTextEquals(MemberRecovery))
		{
			return Elastic.Clients.Elasticsearch.CommonStatsFlag.Recovery;
		}

		if (reader.ValueTextEquals(MemberRefresh))
		{
			return Elastic.Clients.Elasticsearch.CommonStatsFlag.Refresh;
		}

		if (reader.ValueTextEquals(MemberRequestCache))
		{
			return Elastic.Clients.Elasticsearch.CommonStatsFlag.RequestCache;
		}

		if (reader.ValueTextEquals(MemberSearch))
		{
			return Elastic.Clients.Elasticsearch.CommonStatsFlag.Search;
		}

		if (reader.ValueTextEquals(MemberSegments))
		{
			return Elastic.Clients.Elasticsearch.CommonStatsFlag.Segments;
		}

		if (reader.ValueTextEquals(MemberShardStats))
		{
			return Elastic.Clients.Elasticsearch.CommonStatsFlag.ShardStats;
		}

		if (reader.ValueTextEquals(MemberSparseVector))
		{
			return Elastic.Clients.Elasticsearch.CommonStatsFlag.SparseVector;
		}

		if (reader.ValueTextEquals(MemberStore))
		{
			return Elastic.Clients.Elasticsearch.CommonStatsFlag.Store;
		}

		if (reader.ValueTextEquals(MemberTranslog))
		{
			return Elastic.Clients.Elasticsearch.CommonStatsFlag.Translog;
		}

		if (reader.ValueTextEquals(MemberWarmer))
		{
			return Elastic.Clients.Elasticsearch.CommonStatsFlag.Warmer;
		}

		var value = reader.GetString()!;
		if (string.Equals(value, MemberAll.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.CommonStatsFlag.All;
		}

		if (string.Equals(value, MemberBulk.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.CommonStatsFlag.Bulk;
		}

		if (string.Equals(value, MemberCompletion.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.CommonStatsFlag.Completion;
		}

		if (string.Equals(value, MemberDenseVector.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.CommonStatsFlag.DenseVector;
		}

		if (string.Equals(value, MemberDocs.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.CommonStatsFlag.Docs;
		}

		if (string.Equals(value, MemberFielddata.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.CommonStatsFlag.Fielddata;
		}

		if (string.Equals(value, MemberFlush.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.CommonStatsFlag.Flush;
		}

		if (string.Equals(value, MemberGet.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.CommonStatsFlag.Get;
		}

		if (string.Equals(value, MemberIndexing.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.CommonStatsFlag.Indexing;
		}

		if (string.Equals(value, MemberMappings.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.CommonStatsFlag.Mappings;
		}

		if (string.Equals(value, MemberMerge.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.CommonStatsFlag.Merge;
		}

		if (string.Equals(value, MemberQueryCache.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.CommonStatsFlag.QueryCache;
		}

		if (string.Equals(value, MemberRecovery.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.CommonStatsFlag.Recovery;
		}

		if (string.Equals(value, MemberRefresh.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.CommonStatsFlag.Refresh;
		}

		if (string.Equals(value, MemberRequestCache.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.CommonStatsFlag.RequestCache;
		}

		if (string.Equals(value, MemberSearch.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.CommonStatsFlag.Search;
		}

		if (string.Equals(value, MemberSegments.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.CommonStatsFlag.Segments;
		}

		if (string.Equals(value, MemberShardStats.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.CommonStatsFlag.ShardStats;
		}

		if (string.Equals(value, MemberSparseVector.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.CommonStatsFlag.SparseVector;
		}

		if (string.Equals(value, MemberStore.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.CommonStatsFlag.Store;
		}

		if (string.Equals(value, MemberTranslog.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.CommonStatsFlag.Translog;
		}

		if (string.Equals(value, MemberWarmer.Value, System.StringComparison.OrdinalIgnoreCase))
		{
			return Elastic.Clients.Elasticsearch.CommonStatsFlag.Warmer;
		}

		throw new System.Text.Json.JsonException($"Unknown member '{value}' for enum '{nameof(Elastic.Clients.Elasticsearch.CommonStatsFlag)}'.");
	}

	public override void Write(System.Text.Json.Utf8JsonWriter writer, Elastic.Clients.Elasticsearch.CommonStatsFlag value, System.Text.Json.JsonSerializerOptions options)
	{
		switch (value)
		{
			case Elastic.Clients.Elasticsearch.CommonStatsFlag.All:
				writer.WriteStringValue(MemberAll);
				break;
			case Elastic.Clients.Elasticsearch.CommonStatsFlag.Bulk:
				writer.WriteStringValue(MemberBulk);
				break;
			case Elastic.Clients.Elasticsearch.CommonStatsFlag.Completion:
				writer.WriteStringValue(MemberCompletion);
				break;
			case Elastic.Clients.Elasticsearch.CommonStatsFlag.DenseVector:
				writer.WriteStringValue(MemberDenseVector);
				break;
			case Elastic.Clients.Elasticsearch.CommonStatsFlag.Docs:
				writer.WriteStringValue(MemberDocs);
				break;
			case Elastic.Clients.Elasticsearch.CommonStatsFlag.Fielddata:
				writer.WriteStringValue(MemberFielddata);
				break;
			case Elastic.Clients.Elasticsearch.CommonStatsFlag.Flush:
				writer.WriteStringValue(MemberFlush);
				break;
			case Elastic.Clients.Elasticsearch.CommonStatsFlag.Get:
				writer.WriteStringValue(MemberGet);
				break;
			case Elastic.Clients.Elasticsearch.CommonStatsFlag.Indexing:
				writer.WriteStringValue(MemberIndexing);
				break;
			case Elastic.Clients.Elasticsearch.CommonStatsFlag.Mappings:
				writer.WriteStringValue(MemberMappings);
				break;
			case Elastic.Clients.Elasticsearch.CommonStatsFlag.Merge:
				writer.WriteStringValue(MemberMerge);
				break;
			case Elastic.Clients.Elasticsearch.CommonStatsFlag.QueryCache:
				writer.WriteStringValue(MemberQueryCache);
				break;
			case Elastic.Clients.Elasticsearch.CommonStatsFlag.Recovery:
				writer.WriteStringValue(MemberRecovery);
				break;
			case Elastic.Clients.Elasticsearch.CommonStatsFlag.Refresh:
				writer.WriteStringValue(MemberRefresh);
				break;
			case Elastic.Clients.Elasticsearch.CommonStatsFlag.RequestCache:
				writer.WriteStringValue(MemberRequestCache);
				break;
			case Elastic.Clients.Elasticsearch.CommonStatsFlag.Search:
				writer.WriteStringValue(MemberSearch);
				break;
			case Elastic.Clients.Elasticsearch.CommonStatsFlag.Segments:
				writer.WriteStringValue(MemberSegments);
				break;
			case Elastic.Clients.Elasticsearch.CommonStatsFlag.ShardStats:
				writer.WriteStringValue(MemberShardStats);
				break;
			case Elastic.Clients.Elasticsearch.CommonStatsFlag.SparseVector:
				writer.WriteStringValue(MemberSparseVector);
				break;
			case Elastic.Clients.Elasticsearch.CommonStatsFlag.Store:
				writer.WriteStringValue(MemberStore);
				break;
			case Elastic.Clients.Elasticsearch.CommonStatsFlag.Translog:
				writer.WriteStringValue(MemberTranslog);
				break;
			case Elastic.Clients.Elasticsearch.CommonStatsFlag.Warmer:
				writer.WriteStringValue(MemberWarmer);
				break;
			default:
				throw new System.Text.Json.JsonException($"Invalid value '{value}' for enum '{nameof(Elastic.Clients.Elasticsearch.CommonStatsFlag)}'.");
		}
	}

	public override Elastic.Clients.Elasticsearch.CommonStatsFlag ReadAsPropertyName(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options)
	{
		return Read(ref reader, typeToConvert, options);
	}

	public override void WriteAsPropertyName(System.Text.Json.Utf8JsonWriter writer, Elastic.Clients.Elasticsearch.CommonStatsFlag value, System.Text.Json.JsonSerializerOptions options)
	{
		Write(writer, value, options);
	}
}